<template id="search">
<!--  <h1>这是搜索内容</h1>-->
  <div class="search">
<!--      <router-view></router-view>-->
  <!--    头部-->
      <ul class="search_nav">
        <li>
          <router-link to="/search">
            <p class="search" >
              <svg class="icon" aria-hidden="true">
                <use xlink:href="#icon-sousuo"></use>
              </svg>
            </p>
          </router-link>
        </li>
        <li><router-link to="/" @click="go">取消</router-link></li>
      </ul>
  <!--    导航栏-->
<!--      <div class="navtab">-->
<!--        <ul class="nav_tab">-->
<!--          <li v-for="(item,index) in navlist">-->
<!--            {{item.title}}-->
<!--          </li>-->
<!--        </ul>-->
<!--      </div>-->
      <div class="navtab">
        <ul class="nav_tab">
          <li v-for="(item,index) in navlist" v-on:click="change(index)" v-bind:class="{current:index==msg}">
            <router-link :to="navlist[index].path">{{item.title}}</router-link>
            <!--            {{item.title}}-->
          </li>
        </ul>
      </div>

      <router-view></router-view>
  </div>
</template>

<script>
    export default {
        // name: "search"
        data(){
          return{
            msg:0,
            value:'',
            navlist:[
              {
                title: "热门",
                path: "/search_content"
              },
              {
                title: "有声书",
                path: "/search_content_one"
              },
              {
                title: "相声评书",
                path: "/search_content"
              },
              {
                title: "儿童",
                path: "/search_content_one"
              },
              {
                title: "历史",
                path: "/search_content"
              },
              {
                title: "音乐",
                path: "/search_content_one"
              },
              {
                title: "人文",
                path: "/search_content"
              },
              {
                title: "商业财经",
                path: "/search_content_one"
              },
              {
                title: "其它",
                path: "/search_content"
              }
            ],
            contlist:[]
          }
        },
        methods:{
          go(){
            //    返回,数值可以自定义:-1返回上一个页面 -2返回上两个页面
                this.$router.go(-1);
          },
          change(a){
            this.msg=a;
          }
        },
        mounted() {
          var _this=this;
          this.$http.get('./data/search.json')
            .then((response)=>{
              //成功之后的
              // console.log(response);
              // this.navlist=response.data.navlist;
              this.contlist=response.data.contlist;
            })
            .catch(function (err) {
              //失败的
              console.log(err);
            })
            .then(function () {
              //总会执行的
              //always executed
            })
        }
    }
</script>

<style scoped>
  .search{
    position: relative;
  }
  /*<!--  头部header-->*/
  .search_nav{
    display: flex;
    align-items: center;
    /*background-color: purple;*/
    padding: 10px 20px 0;
  }
  .search_nav li{
    /*width: 30%;*/
    /*border:1px solid red;*/
    justify-content: space-between;
  }
  .search_nav li:nth-of-type(1){
    flex-grow: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    margin: 0 5px;
  }
  .search_nav li:nth-of-type(1) svg{
    position: absolute;
    top: 25%;
    left: 5%;
  }
  .search_nav li:nth-of-type(1) .search{
    position: relative;
    border-radius: 30px;
    background-color: #eff1f4;
    border:1px solid #eff1f4;
    /*width: 168px;*/
    height: 30px;
    outline: none;
  }
  .search_nav li:nth-of-type(1)>a{
    color: #7e8c8d;
    display: block;
    width: 100%;
  }
  .search_nav li:nth-of-type(2)>a{
    color: #333;
    padding: 0 0 0 10px;
    font-size: 16px;
    white-space: nowrap;
  }
/*  排行榜内容*/
  .cont_row{
    padding: 10px 20px;
    display: flex;
    flex-direction: column;
  }
  .cont_row li{
    display: flex;
    justify-content: space-around;
    font-size: 16px;
    /*border:1px solid red;*/
    padding: 10px 20px;
  }
  .cont_row li>span{
    display: block;
    flex-grow: 1;
    width: 5%;
    /*border: 1px solid blue;*/
    color: #dabda6;
    font-weight: 500;
    text-align: center;
  }
  .cont_row li:nth-of-type(1)>span,.cont_row li:nth-of-type(2)>span,.cont_row li:nth-of-type(3)>span{
    font-size: 20px;
  }
  .cont_row li:nth-of-type(1)>span{
    color: #ff0b0b;
  }
  .cont_row li:nth-of-type(2)>span{
    color:#f86442 ;
  }
  .cont_row li:nth-of-type(3)>span{
    color: #f8a642;
  }
  .cont_row li>p{
    flex-grow: 2;
    width: 80%;
    padding: 0 10px;
    /*border: 1px solid purple;*/
  }
  .cont_row li>svg{
    /*border: 1px solid gold;*/
    font-size: 10px;
  }
  .above{
    position: absolute;
    bottom: 0;
    height: 175px;
    width: 100%;
    background: rgba(0,0,0,.7);
    padding-top: 60px;
    box-sizing: border-box;
    text-align: center;
    color: #FFFFFF;
    font-weight: 700;
    line-height: 30px;
  }

</style>
